//
//  Forum_Main_ViewController.m
//  Pacific_Computer
//
//  Created by 范琦 on 14-12-17.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "Forum_Main_ViewController.h"
#import "UIColor+AddColor.h"
#import "Infor_Search_ViewController.h"
#import "UIScrollView+MJRefresh.h"
#import "UIScrollView+Extension.h"
#import "Forum_FourPhotos.h"
#import "Forum_Main_detail_ViewController.h"
#import "Forum_Five_Hot.h"
#import "Forum_detail_ViewController.h"
#import "Forum_BHot.h"
#import "Forum_BhotCell.h"
#import "Forum_List.h"
#import "UIImageView+WebCache.h"
#import "Forum_List_detali_Controller.h"
#import "Forum_More_ViewController.h"
#import "NetHandler.h"

@interface Forum_Main_ViewController ()<UIScrollViewDelegate, UITableViewDataSource,UITableViewDelegate>

@property(nonatomic, retain) UIScrollView *scrollAll;
// button下面的两个View
@property(nonatomic, retain) UIView *view1;
@property(nonatomic, retain) UIView *view2;
// 两个小scrollView
@property(nonatomic, retain) UIScrollView *scrollPlaza;
@property(nonatomic, retain) UIScrollView *scrollList;

// 论坛广场上方四图
@property(nonatomic, retain) UIScrollView *scrollPhotos;

@property(nonatomic, retain) NSMutableArray *fourPhotos;
@property(nonatomic, retain) UIPageControl *pageCon;
// 每日热帖
@property(nonatomic, retain) UIScrollView *scrollHot;
@property(nonatomic, retain) NSMutableArray *hotArr;
@property(nonatomic, retain) UIPageControl *hotPageCon;
// 热门板块
@property(nonatomic, retain) UITableView *table;
@property(nonatomic, retain) NSMutableArray *bHotArr;


// 论坛列表
@property(nonatomic, retain) UITableView *tableList;
@property(nonatomic, retain) NSMutableArray *forumList;

@end

@implementation Forum_Main_ViewController
- (void)dealloc
{
    [_scrollAll release];
    [_view1 release];
    [_view2 release];
    [_scrollList release];
    [_scrollPhotos release];
    [_scrollPlaza release];
    [_fourPhotos release];
    [_pageCon release];
    [_scrollHot release];
    [_hotArr release];
    [_hotPageCon release];
    [_table release];
    [_bHotArr release];
    [_tableList release];
    [_forumList release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.translucent = YES;
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    self.navigationController.navigationBar.tintColor  = [UIColor hongse];
    
    self.scrollAll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 30, self.view.bounds.size.width, self.view.bounds.size.height)];
    [self.view addSubview:self.scrollAll];
    self.scrollAll.contentSize = CGSizeMake(self.view.bounds.size.width * 2, 0);
    self.scrollAll.pagingEnabled = YES;
    self.scrollAll.backgroundColor = [UIColor huiseColor];
    self.scrollAll.delegate = self;
    [_scrollAll release];
    
    self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(searchClick:)] autorelease];
    
    
    
    

    UIView *nowView = [[UIView alloc]initWithFrame:CGRectMake(0, 20 + self.navigationController.navigationBar.frame.size.height, self.view.bounds.size.width, self.view.bounds.size.height * 6 / 100)];

    [self.view addSubview:nowView];
    nowView.backgroundColor = [UIColor whiteColor];
    [nowView release];
//    [self.view bringSubviewToFront:nowView];
    
// 论坛广场
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeSystem];
//    button1.backgroundColor = [UIColor hongse];
    [nowView addSubview:button1];
    button1.frame = CGRectMake(self.view.bounds.size.width * 13.33 / 100, 0, nowView.bounds.size.width / 2 - (self.view.bounds.size.width * 13.33 / 100), self.view.bounds.size.height * 4.49 / 100);
    [button1 setTitle:@"论坛广场" forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(button1:) forControlEvents:UIControlEventTouchUpInside];
    button1.tintColor = [UIColor hongse];
    button1.tag = 500;
    self.view1 = [[UIView alloc]initWithFrame:CGRectMake(0, button1.bounds.size.height * 1.1, nowView.bounds.size.width / 2 - (self.view.bounds.size.width * 13.33 / 100), button1.bounds.size.height * 6.66 / 100)];
    [button1 addSubview:self.view1];
    self.view1.backgroundColor = [UIColor hongse];
    [_view1 release];
    
    
    
// 论坛列表
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeSystem];
    [nowView addSubview:button2];
    button2.frame = CGRectMake(nowView.bounds.size.width / 2, 0, nowView.bounds.size.width / 2 - (self.view.bounds.size.width * 13.33 / 100), self.view.bounds.size.height * 4.49 / 100);
    [button2 setTitle:@"论坛列表" forState:UIControlStateNormal];
    [button2 addTarget:self action:@selector(button2:) forControlEvents:UIControlEventTouchUpInside];
    self.view2 = [[UIView alloc]initWithFrame:CGRectMake(0, button2.bounds.size.height * 1.1, nowView.bounds.size.width / 2 - (self.view.bounds.size.width * 13.33 / 100), button2.bounds.size.height * 6.66 / 100)];
    [button2 addSubview:self.view2];
    button2.tag = 501;
    button2.tintColor = [UIColor blackColor];
    self.view2.backgroundColor = [UIColor whiteColor];
    [_view2 release];
    
    
    self.scrollPlaza = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
//    self.scrollPlaza.contentSize = CGSizeMake(0, 1000);
    [self.scrollAll addSubview:self.scrollPlaza];
    self.scrollPlaza.showsVerticalScrollIndicator = NO;
    self.scrollPlaza.backgroundColor = [UIColor huiseColor];
    [_scrollPlaza release];
    
//    self.scrollList = [[UIScrollView alloc]initWithFrame:CGRectMake(self.view.bounds.size.width, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
//    self.scrollList.contentSize = CGSizeMake(0, 1000);
//    [self.scrollAll addSubview:self.scrollList];
//    self.scrollList.backgroundColor = [UIColor huiseColor];
//    [_scrollList release];
    
    
    
    
// 论坛广场=====================
    
    self.scrollPhotos = [[UIScrollView alloc]initWithFrame:CGRectMake(10, 10, self.view.bounds.size.width - 20, self.view.bounds.size.height * 1 / 4)];
    self.scrollPhotos.contentSize = CGSizeMake(self.scrollPhotos.bounds.size.width * 4, 0);
    [self.scrollPlaza addSubview:self.scrollPhotos];
    self.scrollPhotos.pagingEnabled = YES;
    self.scrollPhotos.delegate = self;
    [_scrollPhotos release];
// 循环创建四个imageView 和 pageCon
    for (int i = 0; i < 4; i++) {

        // 四张imageView的创建

        UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(i * self.scrollPhotos.bounds.size.width, 0, self.scrollPhotos.bounds.size.width, self.scrollPhotos.bounds.size.height)];
        [self.scrollPhotos addSubview:imageV];
        [imageV release];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, self.scrollPhotos.bounds.size.height * 4 / 5, self.scrollPhotos.bounds.size.width, self.scrollPhotos.bounds.size.height * 1 / 5)];
        label.backgroundColor = [UIColor clearColor];
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = [UIColor whiteColor];
        [imageV addSubview:label];
        [label release];
        
        UILabel *subLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, label.bounds.size.width, label.bounds.size.height)];
        subLabel.backgroundColor = [UIColor blackColor];
        subLabel.alpha = 0.5;
        [label addSubview:subLabel];
        [subLabel release];
        imageV.tag = 100 + i;
        label.tag = 200 + i;
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        button.frame = CGRectMake(i * self.scrollPhotos.bounds.size.width, 0, self.scrollPhotos.bounds.size.width, self.scrollPhotos.bounds.size.height);
        button.backgroundColor = [UIColor clearColor];
        [button addTarget:self action:@selector(clickButtonPhotos:) forControlEvents:UIControlEventTouchUpInside];
        [self.scrollPhotos addSubview:button];

        

    }
    self.pageCon = [[UIPageControl alloc]initWithFrame:CGRectMake(self.scrollPhotos.bounds.size.width * 4 / 5, self.scrollPhotos.bounds.size.height * 8 / 9, self.scrollPhotos.bounds.size.width * 1 / 4, 20)];
    self.pageCon.numberOfPages = 4;
    self.pageCon.backgroundColor = [UIColor clearColor];
    [self.scrollPlaza addSubview:self.pageCon];
    [self.scrollPlaza bringSubviewToFront:self.pageCon];
    [self.pageCon addTarget:self action:@selector(pageCon:) forControlEvents:UIControlEventValueChanged];
    [_pageCon release];

    
// 六个button的创建
    
// 六个button的网络请求
    
    UIButton *buttonPlaza1 = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonPlaza1.layer.cornerRadius = 3;
    [self.scrollPlaza addSubview:buttonPlaza1];
    buttonPlaza1.frame = CGRectMake(10, self.scrollPhotos.bounds.origin.y + self.scrollPhotos.bounds.size.height + 20, self.scrollPhotos.bounds.size.width / 3 - 10, self.view.bounds.size.height / 10);
    buttonPlaza1.backgroundColor = [UIColor tiankonglan];
    [buttonPlaza1 addTarget:self action:@selector(buttonPlaza:) forControlEvents:UIControlEventTouchUpInside];
    
    UIImageView *imageV1 = [[UIImageView alloc]initWithFrame:CGRectMake(buttonPlaza1.bounds.size.width * 1 / 8, -10, buttonPlaza1.bounds.size.width * 3 / 4, buttonPlaza1.bounds.size.height)];
    [buttonPlaza1 addSubview:imageV1];
    [imageV1 release];
    
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(0, buttonPlaza1.bounds.size.width * 3/ 7 + 3, buttonPlaza1.bounds.size.width, buttonPlaza1.bounds.size.height * 1 / 9)];
    
    label1.text = @"手机";
    [buttonPlaza1 addSubview:label1];
    label1.font = [UIFont systemFontOfSize:15];
    [label1 release];
    label1.textAlignment = NSTextAlignmentCenter;
    label1.textColor = [UIColor whiteColor];
// 第二个按钮
    UIButton *buttonPlaza2 = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonPlaza2.layer.cornerRadius = 3;
    [self.scrollPlaza addSubview:buttonPlaza2];
    buttonPlaza2.frame = CGRectMake(25 + buttonPlaza1.bounds.size.width, self.scrollPhotos.bounds.origin.y + self.scrollPhotos.bounds.size.height + 20, self.scrollPhotos.bounds.size.width / 3 - 10, self.view.bounds.size.height / 10);
    buttonPlaza2.backgroundColor = [UIColor jinjuse];
    [buttonPlaza2 addTarget:self action:@selector(buttonDIY:) forControlEvents:UIControlEventTouchUpInside];
    
    UIImageView *imageV2 = [[UIImageView alloc]initWithFrame:CGRectMake(buttonPlaza2.bounds.size.width * 1 / 8, -10, buttonPlaza2.bounds.size.width * 3 / 4, buttonPlaza2.bounds.size.height)];
    [buttonPlaza2 addSubview:imageV2];
    [imageV2 release];
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(0, buttonPlaza2.bounds.size.width * 3/ 7, buttonPlaza2.bounds.size.width, buttonPlaza2.bounds.size.height * 1 / 4)];
    
    label2.text = @"DIY";
    [buttonPlaza2 addSubview:label2];
    label2.font = [UIFont systemFontOfSize:15];
    [label2 release];
    label2.textAlignment = NSTextAlignmentCenter;
    label2.textColor = [UIColor whiteColor];
// 第三个按钮
    UIButton *buttonPlaza3 = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonPlaza3.layer.cornerRadius = 3;
    [self.scrollPlaza addSubview:buttonPlaza3];
    buttonPlaza3.frame = CGRectMake(buttonPlaza1.bounds.size.width + buttonPlaza2.bounds.size.width + 40, self.scrollPhotos.bounds.origin.y + self.scrollPhotos.bounds.size.height + 20, self.scrollPhotos.bounds.size.width / 3 - 10, self.view.bounds.size.height / 10);
    buttonPlaza3.backgroundColor = [UIColor hongse2];
    [buttonPlaza3 addTarget:self action:@selector(buttonComputer:) forControlEvents:UIControlEventTouchUpInside];
    
    UIImageView *imageV3 = [[UIImageView alloc]initWithFrame:CGRectMake(buttonPlaza3.bounds.size.width * 1 / 8, -10, buttonPlaza3.bounds.size.width * 3 / 4, buttonPlaza3.bounds.size.height)];
    [buttonPlaza3 addSubview:imageV3];
    [imageV3 release];
    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(0, buttonPlaza3.bounds.size.width * 3/ 7, buttonPlaza3.bounds.size.width, buttonPlaza3.bounds.size.height * 1 / 4)];
    
    label3.text = @"笔记本";
    label3.font = [UIFont systemFontOfSize:15];
    [buttonPlaza3 addSubview:label3];
    [label3 release];
    label3.textAlignment = NSTextAlignmentCenter;
    label3.textColor = [UIColor whiteColor];
// 第四个按钮
    UIButton *buttonPlaza4 = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonPlaza4.layer.cornerRadius = 3;
    [self.scrollPlaza addSubview:buttonPlaza4];
    buttonPlaza4.frame = CGRectMake(10, self.scrollPhotos.bounds.origin.y + self.scrollPhotos.bounds.size.height + 30 + buttonPlaza1.bounds.size.height, self.scrollPhotos.bounds.size.width / 3 - 10, self.view.bounds.size.height / 10);
    buttonPlaza4.backgroundColor = [UIColor qianweise];
    [buttonPlaza4 addTarget:self action:@selector(buttonfigure:) forControlEvents:UIControlEventTouchUpInside];
    
    UIImageView *imageV4 = [[UIImageView alloc]initWithFrame:CGRectMake(buttonPlaza4.bounds.size.width * 1 / 8, -10, buttonPlaza4.bounds.size.width * 3 / 4, buttonPlaza4.bounds.size.height)];
    [buttonPlaza4 addSubview:imageV4];
    [imageV4 release];
    
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(0, buttonPlaza4.bounds.size.width * 3/ 7 + 3, buttonPlaza4.bounds.size.width, buttonPlaza4.bounds.size.height * 1 / 9)];
    
    label4.text = @"最数码";
    [buttonPlaza4 addSubview:label4];
    label4.font = [UIFont systemFontOfSize:15];
    [label4 release];
    label4.textAlignment = NSTextAlignmentCenter;
    label4.textColor = [UIColor whiteColor];
// 第五个按钮
    UIButton *buttonPlaza5 = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonPlaza5.layer.cornerRadius = 3;
    [self.scrollPlaza addSubview:buttonPlaza5];
    buttonPlaza5.frame = CGRectMake(25 + buttonPlaza2.bounds.size.width, self.scrollPhotos.bounds.origin.y + self.scrollPhotos.bounds.size.height + 30 + buttonPlaza2.bounds.size.height, self.scrollPhotos.bounds.size.width / 3 - 10, self.view.bounds.size.height / 10);
    buttonPlaza5.backgroundColor = [UIColor luse];
    [buttonPlaza5 addTarget:self action:@selector(buttonUsed:) forControlEvents:UIControlEventTouchUpInside];
    
    UIImageView *imageV5 = [[UIImageView alloc]initWithFrame:CGRectMake(buttonPlaza5.bounds.size.width * 1 / 8, -10, buttonPlaza5.bounds.size.width * 3 / 4, buttonPlaza5.bounds.size.height)];
    [buttonPlaza5 addSubview:imageV5];
    [imageV5 release];
    UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(0, buttonPlaza5.bounds.size.width * 3/ 7, buttonPlaza5.bounds.size.width, buttonPlaza5.bounds.size.height * 1 / 4)];
    
    label5.text = @"二手";
    [buttonPlaza5 addSubview:label5];
    label5.font = [UIFont systemFontOfSize:15];
    [label5 release];
    label5.textAlignment = NSTextAlignmentCenter;
    label5.textColor = [UIColor whiteColor];
// 第六个按钮
    UIButton *buttonPlaza6 = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonPlaza6.layer.cornerRadius = 3;
    [self.scrollPlaza addSubview:buttonPlaza6];
    buttonPlaza6.frame = CGRectMake(buttonPlaza1.bounds.size.width + buttonPlaza2.bounds.size.width + 40, self.scrollPhotos.bounds.origin.y + self.scrollPhotos.bounds.size.height + 30 + buttonPlaza3.bounds.size.height, self.scrollPhotos.bounds.size.width / 3 - 10, self.view.bounds.size.height / 10);
    buttonPlaza6.backgroundColor = [UIColor zhonghuang];
    [buttonPlaza6 addTarget:self action:@selector(buttonFilm:) forControlEvents:UIControlEventTouchUpInside];
    
    UIImageView *imageV6 = [[UIImageView alloc]initWithFrame:CGRectMake(buttonPlaza6.bounds.size.width * 1 / 8, -10, buttonPlaza6.bounds.size.width * 3 / 4, buttonPlaza6.bounds.size.height)];
    [buttonPlaza6 addSubview:imageV6];
    [imageV6 release];
    UILabel *label6 = [[UILabel alloc]initWithFrame:CGRectMake(0, buttonPlaza6.bounds.size.width * 3/ 7, buttonPlaza6.bounds.size.width, buttonPlaza6.bounds.size.height * 1 / 4)];
    
    label6.text = @"摄影";
    label6.font = [UIFont systemFontOfSize:15];
    [buttonPlaza6 addSubview:label6];
    [label6 release];
    label6.textAlignment = NSTextAlignmentCenter;
    label6.textColor = [UIColor whiteColor];
    
    
    
    NSString *str = @"http://mrobot.pconline.com.cn/configs/pconline_v4_bbs_forum_tree";
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    [NetHandler getDataWithUrl:str completion:^(NSData *data) {
        id result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        NSArray *arr = [result objectForKey:@"children"];
        NSMutableArray *arrima = [NSMutableArray array];
        for (NSDictionary *dic in arr) {
            NSArray *arrr = [dic objectForKey:@"me"];
            NSString *sttr = [arrr objectAtIndex:2];
            [arrima addObject:sttr];
        }
        
        for (int i = 0; i < [arrima count]; i++) {
            
            NSString *ss = [arrima objectAtIndex:i];
            if (i == 1) {
                NSURLResponse *response = nil;
                ss = [ss stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:ss] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
                NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:nil];
                UIImage *image = [UIImage imageWithData:data];
                imageV1.image = image;
                
            }else if (i == 2){
                NSURLResponse *response = nil;
                ss = [ss stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:ss] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
                NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:nil];
                UIImage *image = [UIImage imageWithData:data];
                imageV2.image = image;
            }
            else if (i == 3){
                NSURLResponse *response = nil;
                ss = [ss stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:ss] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
                NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:nil];
                UIImage *image = [UIImage imageWithData:data];
                imageV3.image = image;
            }else if (i == 0){
                NSURLResponse *response = nil;
                ss = [ss stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:ss] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
                NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:nil];
                UIImage *image = [UIImage imageWithData:data];
                imageV4.image = image;
            }else if (i == 6){
                NSURLResponse *response = nil;
                ss = [ss stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:ss] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
                NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:nil];
                UIImage *image = [UIImage imageWithData:data];
                imageV5.image = image;
            }else if (i == 5){
                NSURLResponse *response = nil;
                ss = [ss stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:ss] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
                NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:nil];
                UIImage *image = [UIImage imageWithData:data];
                imageV6.image = image;
            }
        }
        
 
    }];
    
// 每日热帖 =======================
    

    UILabel *labelHot = [[UILabel alloc]initWithFrame:CGRectMake(15, self.scrollPlaza.bounds.size.height * 1 / 2, 150, 30)];
    labelHot.text = @"每日热帖";
    [self.scrollPlaza addSubview:labelHot];
    labelHot.font = [UIFont systemFontOfSize:13];
    [labelHot release];
    
    self.scrollHot = [[UIScrollView alloc]initWithFrame:CGRectMake(10, self.scrollPlaza.bounds.size.height * 1 / 2 + 30, self.scrollPhotos.bounds.size.width, self.scrollPhotos.bounds.size.height)];
    [self.scrollPlaza addSubview:self.scrollHot];
    self.scrollHot.contentSize = CGSizeMake(self.scrollPhotos.bounds.size.width * 5, 0);
    self.scrollHot.pagingEnabled = YES;
    self.scrollHot.bounces = NO;
    self.scrollHot.delegate = self;
    [_scrollHot release];
    
    
    
    [self HotHandles];
    
    for (int i = 0; i < 5; i++) {
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(i * self.scrollHot.bounds.size.width, 0, self.scrollHot.bounds.size.width, self.scrollHot.bounds.size.height)];
        view.backgroundColor = [UIColor whiteColor];
        [self.scrollHot addSubview:view];
        [view release];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(i * self.scrollHot.bounds.size.width + 10, 0, self.scrollHot.bounds.size.width - 20, self.scrollHot.bounds.size.height * 1 / 3)];
        [self.scrollHot addSubview:label];
        label.numberOfLines = 0;
        label.tag = 600 + i;
        label.font = [UIFont systemFontOfSize:16];
        [label release];
        
        UILabel *labell = [[UILabel alloc]initWithFrame:CGRectMake(i * self.scrollHot.bounds.size.width + 10, label.bounds.size.height, self.scrollHot.bounds.size.width - 20, self.scrollHot.bounds.size.height * 1 / 4)];
        labell.tag = 700 + i;
        labell.font = [UIFont systemFontOfSize:13];
        labell.textColor = [UIColor shenhuiseColor];
        labell.numberOfLines = 0;
        [self.scrollHot addSubview:labell];
        [labell release];
        
        UILabel *labelforum = [[UILabel alloc]initWithFrame:CGRectMake(i * self.scrollHot.bounds.size.width + 10, self.scrollHot.bounds.size.height * 3 / 5, self.scrollHot.bounds.size.width / 2,self.scrollHot.bounds.size.height * 1 / 4)];
        labelforum.tag = 800 + i;
        labelforum.font = [UIFont systemFontOfSize:13];
        [self.scrollHot addSubview:labelforum];
        labelforum.textColor = [UIColor blueColor];
        [labelforum release];
        
        UILabel *labelFloor = [[UILabel alloc]initWithFrame:CGRectMake(i * self.scrollHot.bounds.size.width + self.scrollHot.bounds.size.width * 5 / 7 - 3, self.scrollHot.bounds.size.height * 3 / 5, self.scrollHot.bounds.size.width / 3, self.scrollHot.bounds.size.height * 1 / 4)];
        labelFloor.tag = 900 + i;
        labelFloor.font = [UIFont systemFontOfSize:13];
        [self.scrollHot addSubview:labelFloor];
        labelFloor.textColor = [UIColor shenhuiseColor];
        [labelFloor release];
        
        UIButton *buttonHot = [UIButton buttonWithType:UIButtonTypeSystem];
        buttonHot.frame = view.frame;
        buttonHot.backgroundColor = [UIColor clearColor];
        [buttonHot addTarget:self action:@selector(clickButtonHot:) forControlEvents:UIControlEventTouchUpInside];
        [self.scrollHot addSubview:buttonHot];
        
    }
    self.hotPageCon = [[UIPageControl alloc]initWithFrame:CGRectMake(self.scrollHot.bounds.size.width * 5 / 7 - 3, self.scrollPlaza.bounds.size.height * 17 / 23, self.scrollPlaza.bounds.size.width / 4, self.scrollHot.bounds.size.height * 1 / 5)];
    self.hotPageCon.numberOfPages = 5;
    self.hotPageCon.backgroundColor = [UIColor clearColor];
    [self.scrollPlaza addSubview:self.hotPageCon];
    [_hotPageCon release];
    self.hotPageCon.currentPageIndicatorTintColor = [UIColor blueColor];
    self.hotPageCon.pageIndicatorTintColor = [UIColor huiseColor];
    [self.scrollPlaza bringSubviewToFront:self.hotPageCon];
    [self.hotPageCon addTarget:self action:@selector(hotPage:) forControlEvents:UIControlEventValueChanged];
    
    

    UIButton *buttonMore = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonMore.tintColor = [UIColor hongse];
    buttonMore.frame = CGRectMake(self.scrollHot.frame.origin.x, self.scrollHot.frame.origin.y + self.scrollHot.bounds.size.height + 3, self.scrollHot.bounds.size.width, 30);
    [buttonMore setTitle:@"查看更多热帖" forState:UIControlStateNormal];
    [self.scrollPlaza addSubview:buttonMore];
    buttonMore.backgroundColor = [UIColor whiteColor];
    [buttonMore addTarget:self action:@selector(buttonMore:) forControlEvents:UIControlEventTouchUpInside];
    
    UILabel *hotlabel = [[UILabel alloc]initWithFrame:CGRectMake(15, self.scrollHot.frame.origin.y + self.scrollHot.bounds.size.height + 40, 150, 30)];
    hotlabel.text = @"热门板块";
    [self.scrollPlaza addSubview:hotlabel];
    hotlabel.font = [UIFont systemFontOfSize:13];
    [hotlabel release];
    
    [self bHotHandles];
    self.table = [[UITableView alloc]initWithFrame:CGRectMake(self.scrollHot.frame.origin.x, hotlabel.frame.origin.y + 40, self.scrollHot.bounds.size.width, 11 * 70) style:UITableViewStylePlain];
    [self.scrollPlaza addSubview:self.table];
    self.table.scrollEnabled = NO;
    self.table.delegate = self;
    self.table.dataSource = self;
    [self.table setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    
    self.table.rowHeight = 70;
    self.scrollPlaza.contentSize = CGSizeMake(0, self.table.frame.origin.y + self.table.bounds.size.height + 130);
    [_table release];
    
    
    
    self.tableList = [[UITableView alloc]initWithFrame:CGRectMake(self.view.bounds.size.width + 5, 64, self.view.bounds.size.width - 10, self.view.bounds.size.height - 130) style:UITableViewStylePlain];
    
    self.tableList.backgroundColor = [UIColor huiseColor];
    self.tableList.delegate = self;
    self.tableList.dataSource = self;
    self.tableList.showsVerticalScrollIndicator = NO;
    [self.scrollAll addSubview:self.tableList];
    self.tableList.rowHeight = 80;
    [_tableList release];
    
    
    
    
    [self setupRefresh];
    
    
    
 
}
// 六个按钮的跳转方法
- (void)buttonPlaza:(UIButton *)button
{
    Forum_Main_detail_ViewController *main = [[Forum_Main_detail_ViewController alloc]init];
    main.Url = @"http://itbbs.pconline.com.cn/mobile/topics.ajax?type=hot_week&forums=587012,769285,675902,768193,769283&singleForum=false&noForums=&ie=utf-8&count=20&showImage=true";
    [self.navigationController pushViewController:main animated:YES];
    [main release];
}
// DIY
- (void)buttonDIY:(UIButton *)button
{
    Forum_Main_detail_ViewController *diy = [[Forum_Main_detail_ViewController alloc]init];
    diy.Url = @"http://itbbs.pconline.com.cn/mobile/topics.ajax?type=hot_week&forums=768253,250,721485,2312407&singleForum=false&noForums=&ie=utf-8&count=20&showImage=true";
    [self.navigationController pushViewController:diy animated:YES];
    [diy release];

}
// 电脑
- (void)buttonComputer:(UIButton *)button
{
    Forum_Main_detail_ViewController *com = [[Forum_Main_detail_ViewController alloc]init];
    com.Url = @"http://itbbs.pconline.com.cn/mobile/topics.ajax?type=hot_week&forums=6,769002,768936,2312275&singleForum=false&noForums=&ie=utf-8&count=20&showImage=true";
    [self.navigationController pushViewController:com animated:YES];
    [com release];
    
}
// 最数码跳转
- (void)buttonFilm:(UIButton *)button
{
    Forum_Main_detail_ViewController *figure = [[Forum_Main_detail_ViewController alloc]init];
    figure.Url = @"http://piebbs.pconline.com.cn/mobile/topics.ajax?type=hot_week&forums=2,48,76,86&singleForum=false&noForums=22&ie=utf-8&count=20&showImage=true";
    [self.navigationController pushViewController:figure animated:YES];
    [figure release];
    
}
// 二手
- (void)buttonUsed:(UIButton *)button
{
    Forum_Main_detail_ViewController *used = [[Forum_Main_detail_ViewController alloc]init];
    used.Url = @"http://itbbs.pconline.com.cn/mobile/topics.ajax?type=new&forums=45,240027,671334,681102&singleForum=false&noForums=&ie=utf-8&count=20&showImage=true";
    [self.navigationController pushViewController:used animated:YES];
    [used release];

}
// 摄影
- (void)buttonfigure:(UIButton *)button
{
    Forum_Main_detail_ViewController *film = [[Forum_Main_detail_ViewController alloc]init];
    film.Url = @"http://itbbs.pconline.com.cn/mobile/topics.ajax?type=hot_week&forums=2312647,768285,762422,762424&singleForum=false&noForums=&ie=utf-8&count=20&showImage=tru";
    [self.navigationController pushViewController:film animated:YES];
    [film release];

}
- (void)buttonMore:(UIButton *)button
{
    Forum_More_ViewController *more = [[Forum_More_ViewController alloc]init];
    [self.navigationController pushViewController:more animated:YES];
    [more release];
}
// 刷新程序
- (void)setupRefresh
{
    //    NSLog(@"进入了setupRefresh");
    // 1.下拉刷新(进入刷新状态就会调用self的headerRereshing)
    
    [self.scrollPlaza addHeaderWithTarget:self action:@selector(headerRereshing)];
    //进入刷新状态(一进入程序就下拉刷新)
    [self.scrollPlaza headerBeginRefreshing];
}
// 每日热帖的网络请求
- (void)HotHandles
{
    self.hotArr = [NSMutableArray array];
    NSString *str = [@"http://itbbs.pconline.com.cn/mobile/topics.ajax?type=hot_day&forums=8,2,240024,41,240022&singleForum=false&noForums=762423,2312647&ie=utf-8&count=1&showImage=false" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:str] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
    request.HTTPMethod = @"GET";
    [self.hotArr removeAllObjects];
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        
        NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES) lastObject];
        NSString *path = [NSString stringWithFormat:@"%@/%ld.aa", docPath,(unsigned long)[str hash]];
       
        if (data != nil) {
            BOOL result1 = [NSKeyedArchiver archiveRootObject:data toFile:path];
            NSLog(@"%d", result1);
            id result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
            NSArray *arr = [result objectForKey:@"hot-topics"];
            for (int i = 0; i < 5; i++) {
                NSDictionary *dic = [arr objectAtIndex:i];
                Forum_Five_Hot *five = [[Forum_Five_Hot alloc]init];
                [five setValuesForKeysWithDictionary:dic];
                [self.hotArr addObject:five];
                UILabel *label = (UILabel *)[self.view viewWithTag:i + 600];
                label.text = five.title;
                
                
                UILabel *label1 = (UILabel *)[self.view viewWithTag:i + 700];
                label1.text = five.message;
                
                
                UILabel *label2 = (UILabel *)[self.view viewWithTag:i + 800];
                label2.text = five.forumName;
                
                NSString *sttr = [NSString stringWithFormat:@"%@阅/%@楼", five.viewCount, five.floor];
                UILabel *label3 = (UILabel *)[self.view viewWithTag:i + 900];
                label3.text = sttr;
                [five release];
            }
        }
        else{
            NSData *pickData = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
            if (pickData != nil) {
                id result = [NSJSONSerialization JSONObjectWithData:pickData options:NSJSONReadingMutableContainers error:nil];
                NSArray *arr = [result objectForKey:@"hot-topics"];
                for (int i = 0; i < 5; i++) {
                    NSDictionary *dic = [arr objectAtIndex:i];
                    Forum_Five_Hot *five = [[Forum_Five_Hot alloc]init];
                    [five setValuesForKeysWithDictionary:dic];
                    [self.hotArr addObject:five];
                    UILabel *label = (UILabel *)[self.view viewWithTag:i + 600];
                    label.text = five.title;
                    
                    
                    UILabel *label1 = (UILabel *)[self.view viewWithTag:i + 700];
                    label1.text = five.message;
                    
                    UILabel *label2 = (UILabel *)[self.view viewWithTag:i + 800];
                    label2.text = five.forumName;
                    
                    NSString *sttr = [NSString stringWithFormat:@"%@阅/%@楼", five.viewCount, five.floor];
                    UILabel *label3 = (UILabel *)[self.view viewWithTag:i + 900];
                    label3.text = sttr;
                    [five release];

            }
          }
        }
    }];
}
// 每日热门板块的网络请求
- (void)bHotHandles
{
    self.bHotArr = [NSMutableArray array];
    NSString *str = [@"http://www.pconline.com.cn/app/nq/1405/intf5401.js" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:str] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
    request.HTTPMethod = @"GET";
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        NSString *path = [NSString stringWithFormat:@"%@/%ld.aa", docPath, (unsigned long)[str hash]];
        if (data != nil) {
            BOOL result1 = [NSKeyedArchiver archiveRootObject:data toFile:path];
            NSLog(@"%d", result1);
            id result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
            NSArray *arr = [result objectForKey:@"forums"];
            for (NSDictionary *dic in arr) {
                Forum_BHot *bHot = [[Forum_BHot alloc]init];
                [bHot setValuesForKeysWithDictionary:dic];
                [self.bHotArr addObject:bHot];
                [bHot release];
                
            }
        }else{
            NSData *picData = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
            if (picData != nil) {
                id result = [NSJSONSerialization JSONObjectWithData:picData options:NSJSONReadingMutableContainers error:nil];
                NSArray *arr = [result objectForKey:@"forums"];
                for (NSDictionary *dic in arr) {
                    Forum_BHot *bHot = [[Forum_BHot alloc]init];
                    [bHot setValuesForKeysWithDictionary:dic];
                    [self.bHotArr addObject:bHot];
                    [bHot release];
                    
                }
            }
        }
        
    }];
}
// 论坛列表的网络请求
- (void)forumListHandles
{
    self.forumList = [NSMutableArray array];
    NSString *str = [@"http://mrobot.pconline.com.cn/configs/pconline_v4_bbs_forum_tree" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:str] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
    request.HTTPMethod = @"GET";
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        NSString *path = [NSString stringWithFormat:@"%@/%ld.aa", docPath, (unsigned long)[str hash]];
        if (data != nil) {
            BOOL result1 = [NSKeyedArchiver archiveRootObject:data toFile:path];
            NSLog(@"%d", result1);
            id result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
            NSArray *arr = [result objectForKey:@"children"];
            for (NSDictionary *dic in arr) {
                NSArray *arrr = [dic objectForKey:@"me"];
                Forum_List *list = [[Forum_List alloc]init];
                list.name = [arrr objectAtIndex:1];
                list.url = [arrr objectAtIndex:2];
                list.num = [arrr objectAtIndex:0];
                [self.forumList addObject:list];
                [list release];
            }
            [self.tableList reloadData];
        }
        else{
            NSData *pickData = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
            if (pickData != nil) {
                id result = [NSJSONSerialization JSONObjectWithData:pickData options:NSJSONReadingMutableContainers error:nil];
                NSArray *arr = [result objectForKey:@"children"];
                for (NSDictionary *dic in arr) {
                    NSArray *arrr = [dic objectForKey:@"me"];
                    Forum_List *list = [[Forum_List alloc]init];
                    list.name = [arrr objectAtIndex:1];
                    list.url = [arrr objectAtIndex:2];
                    list.num = [arrr objectAtIndex:0];
                    [self.forumList addObject:list];
                    [list release];
                }
                [self.tableList reloadData];

            }
        }
    }];
}

- (void)hotPage:(UIPageControl *)page
{
    [self.scrollHot setContentOffset:CGPointMake(page.currentPage * self.scrollHot.bounds.size.width, 0) animated:YES];

}


#pragma mark 开始进入刷新状态
- (void)headerRereshing
{
    
    //1. 在这调用请求网络数据方法（刷新数据）
    [self photosHandls];
    [self HotHandles];
    [self forumListHandles];
    
    
    //2. 2秒后刷新表格UI
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        // 刷新表格
        [self.table reloadData];
        
        // (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态
        [self.scrollPlaza headerEndRefreshing];
    });
}







- (void)photosHandls;
{

    NSString *str = @"http://www.pconline.com.cn/app/bbs/focus/";
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:str] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
    request.HTTPMethod = @"GET";

    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        NSString *path = [NSString stringWithFormat:@"%@/%ld.aa", docPath, (unsigned long)[str hash]];
        if (data != nil) {
            BOOL result1 = [NSKeyedArchiver archiveRootObject:data toFile:path];
            NSLog(@"%d", result1);
            self.fourPhotos = [NSMutableArray array];
            id result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
            NSArray *arr = [result objectForKey:@"focus"];
            for (int i = 0; i < 4; i++) {
                NSDictionary *dic = [arr objectAtIndex:i];
                Forum_FourPhotos *four = [[Forum_FourPhotos alloc]init];
                [four setValuesForKeysWithDictionary:dic];
                [self.fourPhotos addObject:four];
                [four release];
                
                NSString *sttr = [four.image stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:sttr] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
                req.HTTPMethod = @"GET";
                NSURLResponse *response = nil;
                NSData *data1 = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:nil];
                NSString *pathh = [NSString stringWithFormat:@"%@/%ld.aa", docPath, (unsigned long)[sttr hash]];
                if (data1 != nil) {
                    BOOL result1 = [NSKeyedArchiver archiveRootObject:data1 toFile:pathh];
                    NSLog(@"%d", result1);
                    UIImageView *imageV = (UIImageView *)[self.view viewWithTag:i + 100];
                    UIImage *image = [UIImage imageWithData:data1];
                    imageV.image = image;
                    UILabel *label = (UILabel *)[self.view viewWithTag:i + 200];
                    label.text = four.title;
                }else{
                    NSData *pickData1 = [NSKeyedUnarchiver unarchiveObjectWithFile:pathh];
                    if (pickData1 != nil) {
                        UIImageView *imageV = (UIImageView *)[self.view viewWithTag:i + 100];
                        UIImage *image = [UIImage imageWithData:pickData1];
                        imageV.image = image;
                        UILabel *label = (UILabel *)[self.view viewWithTag:i + 200];
                        label.text = four.title;
                    }
                }
            }
            [self.table reloadData];
        }else{
            NSData *pickData = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
            if (pickData != nil) {
                self.fourPhotos = [NSMutableArray array];
                id result = [NSJSONSerialization JSONObjectWithData:pickData options:NSJSONReadingMutableContainers error:nil];
                NSArray *arr = [result objectForKey:@"focus"];
                for (int i = 0; i < 4; i++) {
                    NSDictionary *dic = [arr objectAtIndex:i];
                    Forum_FourPhotos *four = [[Forum_FourPhotos alloc]init];
                    [four setValuesForKeysWithDictionary:dic];
                    [self.fourPhotos addObject:four];
                    [four release];
                    
                    NSString *sttr = [four.image stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                    NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:sttr] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
                    req.HTTPMethod = @"GET";
                    NSURLResponse *response = nil;
                    NSData *data1 = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:nil];
                    NSString *pathh = [NSString stringWithFormat:@"%@/%ld.aa", docPath, (unsigned long)[sttr hash]];
                    if (data1 != nil) {
                        BOOL result1 = [NSKeyedArchiver archiveRootObject:data1 toFile:pathh];
                        NSLog(@"%d", result1);
                        UIImageView *imageV = (UIImageView *)[self.view viewWithTag:i + 100];
                        UIImage *image = [UIImage imageWithData:data1];
                        imageV.image = image;
                        UILabel *label = (UILabel *)[self.view viewWithTag:i + 200];
                        label.text = four.title;
                    }else{
                        NSData *pickData1 = [NSKeyedUnarchiver unarchiveObjectWithFile:pathh];
                        if (pickData1 != nil) {
                            UIImageView *imageV = (UIImageView *)[self.view viewWithTag:i + 100];
                            UIImage *image = [UIImage imageWithData:pickData1];
                            imageV.image = image;
                            UILabel *label = (UILabel *)[self.view viewWithTag:i + 200];
                            label.text = four.title;
                        }
                    }

                }
                [self.table reloadData];
            }
        }
    }];
}


// pageCon的改变
- (void)pageCon:(UIPageControl *)page
{
    self.scrollPhotos.contentOffset =  CGPointMake(self.pageCon.currentPage * 355, 0);

}


// 减速停止 协议
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    if (scrollView == self.scrollAll) {
        if (self.scrollAll.contentOffset.x == 0) {
            self.view1.backgroundColor = [UIColor hongse];
            self.view2.backgroundColor = [UIColor whiteColor];
        }
        else if (self.scrollAll.contentOffset.x == self.view.bounds.size.width){
            self.view1.backgroundColor = [UIColor whiteColor];
            self.view2.backgroundColor = [UIColor hongse];
            self.tableList.frame = CGRectMake(self.view.bounds.size.width + 5, 0, self.view.bounds.size.width - 10, self.view.bounds.size.height - 130);
        }
    }
    if (scrollView == self.scrollPhotos) {
        
        self.pageCon.currentPage = self.scrollPhotos.contentOffset.x / self.scrollPhotos.bounds.size.width;
    }
    if(scrollView == self.scrollHot){
        self.hotPageCon.currentPage = self.scrollHot.contentOffset.x / self.scrollHot.bounds.size.width;
    }

}
// tableView协议
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView == self.table) {
        
        if (self.bHotArr.count == 0) {
            return 0;
        }
        else{
            return self.bHotArr.count;
        }
    }
    else if(tableView == self.tableList){
        if (self.forumList.count == 0) {
            return 0;
        }
        else{
            return self.forumList.count;
        }
    
    }
    return 0;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == self.table) {
        Forum_BhotCell *cell = [tableView dequeueReusableCellWithIdentifier:@"a"];
        if (cell == nil) {
            cell = [[[Forum_BhotCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"a"] autorelease];
        }
        Forum_BHot *bHot = [self.bHotArr objectAtIndex:indexPath.row];
        NSString *str = [NSString stringWithFormat:@"帖子数:%@", bHot.topics];
        
        cell.main.text = bHot.forumName;
        cell.count.text = str;
        cell.count.font = [UIFont systemFontOfSize:14];
        
        return cell;
    }else{
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"b"];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"b"] autorelease];
        }
        Forum_List *list = [self.forumList objectAtIndex:indexPath.row];
        cell.textLabel.text = list.name;
        [cell.imageView setImageWithURL:[NSURL URLWithString:list.url]];
        return cell;
    }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    Forum_BHot *bHot = [self.bHotArr objectAtIndex:indexPath.row];
    Forum_List_detali_Controller *list = [[Forum_List_detali_Controller alloc]init];
    list.bHot = bHot;
    [self.navigationController pushViewController:list animated:YES];
    [list release];

}



// scrollHot上面盖的button按钮
- (void)clickButtonHot:(UIButton *)button
{
    if (self.hotArr.count != 0) {
        Forum_Five_Hot *five = [self.hotArr objectAtIndex:self.hotPageCon.currentPage];
        Forum_detail_ViewController *detail = [[Forum_detail_ViewController alloc]init];
        detail.five = five;
        [self.navigationController pushViewController:detail animated:YES];
        [detail release];
    }

}

- (void)clickButtonPhotos:(UIButton *)button
{
    Forum_detail_ViewController *detail = [[Forum_detail_ViewController alloc]init];
    Forum_FourPhotos *four = [self.fourPhotos objectAtIndex:self.pageCon.currentPage];
    detail.four = four;
    [self.navigationController pushViewController:detail animated:YES];
    [four release];

}

// 两个button  论坛广r场和论坛列表
- (void)button1:(UIButton *)button
{
    self.scrollAll.contentOffset = CGPointMake(0, 0);
    self.view1.backgroundColor = [UIColor hongse];
    self.view2.backgroundColor = [UIColor whiteColor];
    UIButton *button2 = (UIButton *)[self.view viewWithTag:501];
    button2.tintColor = [UIColor blackColor];
    button.tintColor = [UIColor hongse];
    
}
- (void)button2:(UIButton *)button
{
    self.scrollAll.contentOffset = CGPointMake(self.view.bounds.size.width, 0);
    self.view2.backgroundColor = [UIColor hongse];
    self.view1.backgroundColor = [UIColor whiteColor];
    UIButton *button2 = (UIButton *)[self.view viewWithTag:500];
    button2.tintColor = [UIColor blackColor];
    button.tintColor = [UIColor hongse];
}

// 搜索页面
- (void)searchClick:(UIBarButtonItem *)button
{
    Infor_Search_ViewController *search = [[Infor_Search_ViewController alloc]init];
    [self.navigationController pushViewController:search animated:YES];
//    [self presentViewController:search animated:YES completion:^{
//    }];
    [search release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
